from pymysql import Connection

# 获取Mysql数据库连接对象
conn = Connection(
    host="localhost",
    port=3306,
    user="root",
    password="password",
    # 自动提交
    autocommit=True,
)

print(conn.get_server_info())

# 获取游标对象
cursor = conn.cursor()
# 选择数据库
conn.select_db("mytest")
# 使用游标对象执行sql语句
cursor.execute("INSERT INTO test_pymysql VALUES (4, 'hello')")
# # 提交
# conn.commit()
# 关闭连接
conn.close()
